package com.usian.service.impl;

import com.usian.mapper.ProductMapper;
import com.usian.mapper.UserMapper;
import com.usian.pojo.Product;
import com.usian.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private UserMapper productMapper;


    @Override
    public List<Product> productfindAll() {
        int id=2;
        return productMapper.productfindAll(id);
    }

    @Override
    public void productAdd(Integer id) {
        Product product=productMapper.selectById(id);
        product.setStatus(3);
        productMapper.updateById(product);
    }

    @Override
    public Product productUp(Integer id) {
        return productMapper.selectById(id);
    }

    @Override
    public void product(Product product) {
        Product product1=productMapper.selectById(product.getId());
        product1.setStatus(4);
        product1.setBirthday(product.getBirthday());
        productMapper.updateById(product1);
    }

    @Override
    public List<Product> productShang() {
        int id=3;
        return productMapper.productShang(id);
    }

    @Override
    public void products(Integer id) {
        Product product=productMapper.selectById(id);
        if(product.getStatus()==3){
            product.setStatus(5);
        }else if(product.getStatus()==5){
            product.setStatus(6);
        }
        productMapper.updateById(product);
    }
}
